home *** CD-ROM | disk | FTP | other *** search
/ Champak 74 / Volume 74 My Disc - Damaged.iso / Games / remote_control.swf / scripts / frame_1 / DoAction.as
Text File  |  2008-08-08  |  11KB  |  522 lines

  1. function changeChannel()
  2. {
  3.    if(whoHasRemote == "player")
  4.    {
  5.       if(altShows1)
  6.       {
  7.          Television.gotoAndStop(playerSelected + "_alt1");
  8.       }
  9.       else if(altShows2)
  10.       {
  11.          Television.gotoAndStop(playerSelected + "_alt2");
  12.       }
  13.       else
  14.       {
  15.          Television.gotoAndStop(playerSelected);
  16.       }
  17.    }
  18.    else if(whoHasRemote == "opponent")
  19.    {
  20.       if(altShows1)
  21.       {
  22.          if(playerSelected == "brother")
  23.          {
  24.             Television.gotoAndStop("sister_alt1");
  25.          }
  26.          else
  27.          {
  28.             Television.gotoAndStop("brother_alt1");
  29.          }
  30.       }
  31.       else if(altShows2)
  32.       {
  33.          if(playerSelected == "brother")
  34.          {
  35.             Television.gotoAndStop("sister_alt2");
  36.          }
  37.          else
  38.          {
  39.             Television.gotoAndStop("brother_alt2");
  40.          }
  41.       }
  42.       else if(playerSelected == "brother")
  43.       {
  44.          Television.gotoAndStop("sister");
  45.       }
  46.       else
  47.       {
  48.          Television.gotoAndStop("brother");
  49.       }
  50.    }
  51. }
  52. function clearScreen()
  53. {
  54.    if(lateNite == true)
  55.    {
  56.       removeMovieClip("LateNite");
  57.    }
  58.    removeMovieClip("Interface");
  59.    removeMovieClip("Player");
  60.    removeMovieClip("Opponent");
  61.    removeMovieClip("EndTable1");
  62.    removeMovieClip("EndTable2");
  63.    removeMovieClip("CoffeeTable");
  64.    removeMovieClip("Ottoman1");
  65.    removeMovieClip("Ottoman2");
  66.    removeMovieClip("Sofa");
  67. }
  68. function levelUp()
  69. {
  70.    level++;
  71.    playerMoveSpeed++;
  72.    playerFreezeCount += 5;
  73.    opponentMoveSpeed++;
  74.    opponentFreezeCount -= 5;
  75. }
  76. function chooseOpponentDir()
  77. {
  78.    if(whoHasRemote == "player")
  79.    {
  80.       var _loc2_ = Player._x - Opponent._x;
  81.       var _loc3_ = Player._y - Opponent._y;
  82.    }
  83.    else if(whoHasRemote == "opponent")
  84.    {
  85.       _loc2_ = Opponent._x - Player._x;
  86.       _loc3_ = Opponent._y - Player._y;
  87.    }
  88.    var _loc1_ = [];
  89.    _loc1_.push(checkMazeHit(Opponent._x,Opponent._y - 50));
  90.    _loc1_.push(checkMazeHit(Opponent._x,Opponent._y + 50));
  91.    _loc1_.push(checkMazeHit(Opponent._x - 50,Opponent._y));
  92.    _loc1_.push(checkMazeHit(Opponent._x + 50,Opponent._y));
  93.    if(_loc2_ < 0 && _loc3_ < 0)
  94.    {
  95.       if(randInt(1,2) == 1)
  96.       {
  97.          if(_loc1_[0] == false)
  98.          {
  99.             dir = "up";
  100.          }
  101.          else
  102.          {
  103.             dir = "left";
  104.          }
  105.       }
  106.       else
  107.       {
  108.          dir = "left";
  109.       }
  110.    }
  111.    else if(_loc2_ == 0 && _loc3_ < 0)
  112.    {
  113.       if(_loc1_[0] == false)
  114.       {
  115.          dir = "up";
  116.       }
  117.       else if(randInt(1,2) == 1)
  118.       {
  119.          dir = "left";
  120.       }
  121.       else
  122.       {
  123.          dir = "right";
  124.       }
  125.    }
  126.    else if(_loc2_ > 0 && _loc3_ < 0)
  127.    {
  128.       if(randInt(1,2) == 1)
  129.       {
  130.          if(_loc1_[0] == false)
  131.          {
  132.             dir = "up";
  133.          }
  134.          else
  135.          {
  136.             dir = "right";
  137.          }
  138.       }
  139.       else
  140.       {
  141.          dir = "right";
  142.       }
  143.    }
  144.    else if(_loc2_ > 0 && _loc3_ == 0)
  145.    {
  146.       if(_loc1_[3] == false)
  147.       {
  148.          dir = "right";
  149.       }
  150.       else if(randInt(1,2) == 1)
  151.       {
  152.          dir = "up";
  153.       }
  154.       else
  155.       {
  156.          dir = "down";
  157.       }
  158.    }
  159.    else if(_loc2_ > 0 && _loc3_ > 0)
  160.    {
  161.       if(randInt(1,2) == 1)
  162.       {
  163.          if(_loc1_[1] == false)
  164.          {
  165.             dir = "down";
  166.          }
  167.          else
  168.          {
  169.             dir = "right";
  170.          }
  171.       }
  172.       else
  173.       {
  174.          dir = "right";
  175.       }
  176.    }
  177.    else if(_loc2_ == 0 && _loc3_ > 0)
  178.    {
  179.       if(_loc1_[1] == false)
  180.       {
  181.          dir = "down";
  182.       }
  183.       else if(randInt(1,2) == 1)
  184.       {
  185.          dir = "left";
  186.       }
  187.       else
  188.       {
  189.          dir = "right";
  190.       }
  191.    }
  192.    else if(_loc2_ < 0 && _loc3_ > 0)
  193.    {
  194.       if(randInt(1,2) == 1)
  195.       {
  196.          if(_loc1_[1] == false)
  197.          {
  198.             dir = "down";
  199.          }
  200.          else
  201.          {
  202.             dir = "left";
  203.          }
  204.       }
  205.       else
  206.       {
  207.          dir = "left";
  208.       }
  209.    }
  210.    else if(_loc2_ < 0 && _loc3_ == 0)
  211.    {
  212.       if(_loc1_[2] == false)
  213.       {
  214.          dir = "left";
  215.       }
  216.       else if(randInt(1,2) == 1)
  217.       {
  218.          dir = "up";
  219.       }
  220.       else
  221.       {
  222.          dir = "down";
  223.       }
  224.    }
  225.    else if(_loc2_ == 0 && _loc2_ == 0)
  226.    {
  227.       var _loc4_ = randInt(1,4);
  228.       if(_loc4_ == 1)
  229.       {
  230.          dir = "up";
  231.       }
  232.       if(_loc4_ == 2)
  233.       {
  234.          dir = "down";
  235.       }
  236.       if(_loc4_ == 3)
  237.       {
  238.          dir = "left";
  239.       }
  240.       if(_loc4_ == 4)
  241.       {
  242.          dir = "right";
  243.       }
  244.    }
  245.    return dir;
  246. }
  247. function moveAvatar(theClip, theDir)
  248. {
  249.    var _loc6_ = Math.floor(theClip._y / 50) - 1;
  250.    var _loc5_ = Math.floor(theClip._x / 50);
  251.    if(theDir == "up")
  252.    {
  253.       destX = theClip._x;
  254.       destY = theClip._y - theClip.moveSpeed;
  255.       edgeX = destX;
  256.       edgeY = destY - 49;
  257.    }
  258.    else if(theDir == "down")
  259.    {
  260.       destX = theClip._x;
  261.       destY = theClip._y + theClip.moveSpeed;
  262.       edgeX = destX;
  263.       edgeY = destY - 1;
  264.    }
  265.    else if(theDir == "left")
  266.    {
  267.       destX = theClip._x - theClip.moveSpeed;
  268.       destY = theClip._y;
  269.       edgeX = destX - 24;
  270.       edgeY = destY - 1;
  271.    }
  272.    else if(theDir == "right")
  273.    {
  274.       destX = theClip._x + theClip.moveSpeed;
  275.       destY = theClip._y;
  276.       edgeX = destX + 24;
  277.       edgeY = destY - 1;
  278.    }
  279.    var _loc4_ = Math.floor(edgeY / 50);
  280.    var _loc3_ = Math.floor(edgeX / 50);
  281.    if(!checkMazeHit(edgeX,edgeY,theDir))
  282.    {
  283.       theClip._x = destX;
  284.       theClip._y = destY;
  285.       theClip.moveDir = theDir;
  286.       theClip.gotoAndStop(theDir);
  287.    }
  288.    else
  289.    {
  290.       if(theDir == "up")
  291.       {
  292.          theClip._y = (_loc4_ + 1) * 50 + 50;
  293.       }
  294.       else if(theDir == "down")
  295.       {
  296.          theClip._y = _loc4_ * 50;
  297.       }
  298.       else if(theDir == "left")
  299.       {
  300.          theClip._x = (_loc3_ + (_loc5_ - _loc3_)) * 50 + 25;
  301.       }
  302.       else if(theDir == "right")
  303.       {
  304.          theClip._x = _loc3_ * 50 - 25;
  305.       }
  306.       theClip.moveDir = null;
  307.       theClip.gotoAndStop("stopped");
  308.    }
  309. }
  310. function checkMazeHit(posX, posY, theDir)
  311. {
  312.    if(theDir == "up")
  313.    {
  314.       if(MazeWalls.hitTest(posX,posY,true))
  315.       {
  316.          return true;
  317.       }
  318.       return false;
  319.    }
  320.    if(theDir == "down")
  321.    {
  322.       if(MazeWalls.hitTest(posX,posY,true))
  323.       {
  324.          return true;
  325.       }
  326.       return false;
  327.    }
  328.    if(theDir == "left")
  329.    {
  330.       if(MazeWalls.hitTest(posX,posY,true))
  331.       {
  332.          return true;
  333.       }
  334.       return false;
  335.    }
  336.    if(theDir == "right")
  337.    {
  338.       if(MazeWalls.hitTest(posX,posY,true))
  339.       {
  340.          return true;
  341.       }
  342.       return false;
  343.    }
  344.    if(theDir == undefined)
  345.    {
  346.       if(!MazeWalls.hitTest(posX,posY - 49,true))
  347.       {
  348.          if(!MazeWalls.hitTest(posX,posY - 49,true))
  349.          {
  350.             if(!MazeWalls.hitTest(posX,posY - 1,true))
  351.             {
  352.                if(!MazeWalls.hitTest(posX,posY - 1,true))
  353.                {
  354.                   return false;
  355.                }
  356.                return true;
  357.             }
  358.             return true;
  359.          }
  360.          return true;
  361.       }
  362.       return true;
  363.    }
  364. }
  365. function decrementTimer()
  366. {
  367.    if(gameInPlay)
  368.    {
  369.       if(secondsLeft == 0)
  370.       {
  371.          if(minutesLeft == 0)
  372.          {
  373.             clearInterval(timerCode);
  374.             var _loc1_ = playerMinutes * 60 + playerSeconds;
  375.             var _loc2_ = opponentMinutes * 60 + opponentSeconds;
  376.             if(_loc1_ > _loc2_)
  377.             {
  378.                gotoAndStop("WinLevel");
  379.                play();
  380.             }
  381.             else
  382.             {
  383.                gotoAndStop("GameOver");
  384.                play();
  385.             }
  386.          }
  387.          else
  388.          {
  389.             secondsLeft = 59;
  390.             minutesLeft--;
  391.             awardPoint();
  392.          }
  393.       }
  394.       else
  395.       {
  396.          secondsLeft--;
  397.          awardPoint();
  398.       }
  399.    }
  400. }
  401. function awardPoint()
  402. {
  403.    if(whoHasRemote == "player")
  404.    {
  405.       if(playerSeconds == 59)
  406.       {
  407.          playerSeconds = 0;
  408.          playerMinutes++;
  409.       }
  410.       else
  411.       {
  412.          playerSeconds++;
  413.       }
  414.    }
  415.    else if(whoHasRemote == "opponent")
  416.    {
  417.       if(opponentSeconds == 59)
  418.       {
  419.          opponentSeconds = 0;
  420.          opponentMinutes++;
  421.       }
  422.       else
  423.       {
  424.          opponentSeconds++;
  425.       }
  426.    }
  427. }
  428. function setTimerDigits(theMins, theSecs, theClip)
  429. {
  430.    minutesText = String(theMins);
  431.    secondsText = String(theSecs);
  432.    if(minutesText.length < 2)
  433.    {
  434.       theClip.mins1 = "";
  435.       theClip.mins2 = minutesText;
  436.    }
  437.    else
  438.    {
  439.       theClip.mins1 = minutesText.substr(0,1);
  440.       theClip.mins2 = minutesText.substr(1,1);
  441.    }
  442.    if(secondsText.length < 2)
  443.    {
  444.       theClip.secs1 = "0";
  445.       theClip.secs2 = secondsText;
  446.    }
  447.    else
  448.    {
  449.       theClip.secs1 = secondsText.substr(0,1);
  450.       theClip.secs2 = secondsText.substr(1,1);
  451.    }
  452. }
  453. function randInt(num0, num1)
  454. {
  455.    if(arguments.length == 1)
  456.    {
  457.       return Math.round(Math.random() * num0);
  458.    }
  459.    return Math.round(Math.random() * Math.abs(num0 - num1)) + num0;
  460. }
  461. function shuffle(theArray)
  462. {
  463.    i = 0;
  464.    while(i < theArray.length - 1)
  465.    {
  466.       var _loc2_ = Math.round(Math.random() * i);
  467.       var _loc3_ = theArray[i];
  468.       theArray[i] = theArray[_loc2_];
  469.       theArray[_loc2_] = _loc3_;
  470.       i++;
  471.    }
  472.    return theArray;
  473. }
  474. getURL("FSCommand:allowscale",false);
  475. var playerSelected = "";
  476. clearScreen();
  477. stop();
  478. funcHITBOX = function(arString)
  479. {
  480.    trace(arString);
  481.    getURL("javascript:_hbPageView (\'/gamepad/play/games/RemoteControlRuckus/game/" + arString + "\', \'/\')","");
  482. };
  483. keyHandler = new Object();
  484. keyHandler.onKeyDown = function()
  485. {
  486.    if(Key.getCode() == 38)
  487.    {
  488.       upKeyDown = true;
  489.    }
  490.    if(Key.getCode() == 40)
  491.    {
  492.       downKeyDown = true;
  493.    }
  494.    if(Key.getCode() == 37)
  495.    {
  496.       leftKeyDown = true;
  497.    }
  498.    if(Key.getCode() == 39)
  499.    {
  500.       rightKeyDown = true;
  501.    }
  502. };
  503. keyHandler.onKeyUp = function()
  504. {
  505.    if(Key.getCode() == 38)
  506.    {
  507.       upKeyDown = false;
  508.    }
  509.    if(Key.getCode() == 40)
  510.    {
  511.       downKeyDown = false;
  512.    }
  513.    if(Key.getCode() == 37)
  514.    {
  515.       leftKeyDown = false;
  516.    }
  517.    if(Key.getCode() == 39)
  518.    {
  519.       rightKeyDown = false;
  520.    }
  521. };
  522.